package com.hyny.framework.platform.system.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
/**
 * 自定义数据权限枚举
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum DataPowerTypeEnum {
    ADD("ADD", "区域"),
    PROVINCE_CODE("province_code", "省份"),
    CITY_CODE("city_code", "城市"),
    DISTRICT_CODE("district_code", "区县");

    /**
     * 业务字段名称（关联表对应的字段）
     **/
    private String fieldName;
    /**
     * 业务字段显示名称
     */
    private String fieldTitle;

    /**
     * 根据 字段名称，获取enum
     *
     * @return
     * @dto fieldName
     */
    public static DataPowerTypeEnum getEnum(String fieldName) {
        DataPowerTypeEnum[] enums = values();
        int count = enums.length;

        for (int i = 0; i < count; ++i) {
            DataPowerTypeEnum obj = enums[i];
            if (obj.getFieldName().equals(fieldName)) {
                return obj;
            }
        }

        return null;
    }

}